
<%@include file="connection.jsp"%>

<%

	String userid = (String) session.getAttribute("userid");

    if (userid == null)
    {
       response.sendRedirect("login.jsp");
    }
    
    
            Connection c = getConnection();
            Statement s = c.createStatement();

            String patient_id = request.getParameter("patient_id");
            String icd_code[] = request.getParameterValues("icd_code");
            String cpt_code[] = request.getParameterValues("cpt_code");

            if (icd_code != null) {
                for (int i = 0; i < icd_code.length; i++) {
                    s.executeUpdate("insert into tblpatientdiag (PatientID, DiagCode) values('" + patient_id + "', '" + icd_code[i] + "')");
                }
            }

            if (cpt_code != null) {
                for (int i = 0; i < cpt_code.length; i++) {
                    s.executeUpdate("insert into tblpatientproc (PatientID, ProcCode) values('" + patient_id + "', '" + cpt_code[i] + "')");
                }
            }
            
            out.print("Data Saved.");
            
            s.close();
            c.close();
            
            response.sendRedirect("home.jsp?saved=1");
            
%>
<a href="home.jsp"/>Back</a>
